package 简单.长度最小的子数组;

/**
 * @author liugongding
 * @description:
 * @date 2024/9/1 9:32 PM
 */
public class Solution {

    public static int minSubArrayLen(int target, int[] nums) {
        int result = Integer.MAX_VALUE;
        int sum = 0;
        int left = 0;
        for (int right = 0; right < nums.length; right++) {
            sum += nums[right];
            while (sum >= target) {
                int subArrayLength = right - left + 1;
                result = Math.min(subArrayLength, result);
                sum = sum - nums[left];
                left++;
            }
        }
        return Math.max(result,0);
    }

    public static void main(String[] args) {
        int[] a = {5,1,3,5,10,7,4,9,2,8};
        System.out.println(minSubArrayLen(15, a));

        System.out.println("abfcd".contains("abc"));
    }

}
